package com.example.database.controller;

import com.example.database.entity.AdmissionForm;
import com.example.database.entity.LeavingForm;
import com.example.database.entity.Student;
import com.example.database.service.AdminService;
import com.example.database.service.StudentService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = "/admin")
public class AdminController
{
    @Resource
    private AdminService adminService;

    @Resource
    private StudentService studentService;

    @GetMapping(value = "/admission_form")
    public List<AdmissionForm> getAdmissionForm()
    {
        return adminService.getAdmissionForm();
    }

    @GetMapping(value = "/leaving_form")
    public List<LeavingForm> getLeavingForm()
    {
        return adminService.getLeavingForm();
    }

    @GetMapping(value = "/most_admission_student/all")
    public List<Student> findMostAdmissionStudentAll()
    {
        return studentService.findMostAdmissionStudentAll();
    }

    @GetMapping(value = "/most_admission_student/dept")
    List<Student> findMostAdmissionStudentByDept(@RequestParam(value = "deptId") Integer deptId)
    {
        return studentService.findMostAdmissionStudentByDept(deptId);
    }

    @GetMapping(value = "/most_admission_student/class")
    List<Student> findMostAdmissionStudentByClass(@RequestParam(value = "classId") Integer classId)
    {
        return studentService.findMostAdmissionStudentByClass(classId);
    }

}
